//
//  XCCycleDataSource.swift
//  XCCycleBanner
//
//  Created by edy on 2023/7/10.
//

import Foundation


public protocol XCCycleDataSource: AnyObject {
    /// 注册Cell
    func xcBanner(banner: XCCycleType) -> (XCCycleCellRegister)

    /// 资源个数
    func xcBanner(numberOfItems: XCCycleType) -> Int
    
    /// 自定义Cell内容
    func xcBanner(banner: XCCycleType,
                  cellForItemAt index: Int,
                  cell: UICollectionViewCell) -> UICollectionViewCell
    
    /// 相关配置 自动滚动，时间间隔等
    func xcBanner(banner: XCCycleType,
                  params: XCCycleParams) -> XCCycleParams
    
    /// UI布局设置间距 大小
    func xcBanner(banner: XCCycleType,
                  layoutParams: XCCycleLayoutParams) -> XCCycleLayoutParams
    
    /// 添加JXPageControl
    func xcBanner(pageControl: XCCycleType,
                  numberOfPages: Int,
                  coverView: UIView,
                  builder: XCCyclePageControl) -> XCCyclePageControl?
}


/// The default implementation
public extension XCCycleDataSource {
    
    /// 默认配置
    func xcBanner(banner: XCCycleType,
                  params: XCCycleParams) -> XCCycleParams {
        return params
    }
    
    /// 默认配置
    func xcBanner(banner: XCCycleType,
                  layoutParams: XCCycleLayoutParams) -> XCCycleLayoutParams {
        return layoutParams
    }
    
    /// 默认配置
    func xcBanner(pageControl: XCCycleType, numberOfPages: Int, coverView: UIView, builder: XCCyclePageControl) -> XCCyclePageControl? {
        return nil
    }
    
}
